
// 将玩家移出队伍 {"序列":4}

// @ts-ignore
export async function execute(client_id,message_json) {
    let index = message_json["序列"];
    if (index === undefined || index <= 0) {
        ClientUtils.send_basic_prompt(client_id, "你还没有选择玩家");
        return;
    }
    if (index - 1 === 0) {
        ClientUtils.send_basic_prompt(client_id, "不能移出队长");
        return;
    }
    
    let login_characters = G.Characters.get_current_login_characters(client_id);
    if (!login_characters["队长"]) {
        ClientUtils.send_basic_prompt(client_id, "你不是队长没有权限操作");
        return;
    }

    
    let team_data = G.TeamUtils.get_team_data(login_characters["队伍"]);
    if (team_data === undefined) {
        ClientUtils.send_basic_prompt(client_id, "队伍已不存在");
        return;
    }
    let target = team_data["成员"][index - 1];
    if (target === undefined) {
        ClientUtils.send_basic_prompt(client_id, "队员不存在");
        return;
    }
    if (G.TeamUtils.remove_team_characters(login_characters["队伍"], target)) {
        let character_client_id = G.Characters.get_characters_client_id(target);
        if (character_client_id !== undefined) {
           ClientUtils.send_basic_prompt(character_client_id, "你已被踢出队伍");
           ClientUtils.send_client_message(character_client_id, 4004, {});
           ClientUtils.send_client_message(character_client_id, 4021, {});
        }
    };
}

